import type {RouteRecordRaw} from "vue-router";
import {_404Page, _Layout} from "@/router/constant.router";
import {sessionStorage} from "@/utils/StorageUtils.ts";

export const LoginRoute: RouteRecordRaw = {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/template/login.vue'),
    meta: {
        title: '登录',
    },
};

export const MainRoute: RouteRecordRaw = {
    path: '/home',
    name: 'Home',
    component: _Layout,
    meta: {
        title: '后台管理系统',
    },
    children: [
        {
            path: '',
            name: 'HomePage',
            component: () => import('@/views/template/home.vue'),
        },
    ],
};

// 404 on a page
export const ErrorPageRoute: RouteRecordRaw = sessionStorage.get('isLogin') === 'true' ? {
    path: '/:path(.*)*',
    name: 'ErrorPage',
    meta: {
        title: 'ErrorPage',
        hideBreadcrumb: true,
    },
    component: _Layout,
    children: [
        {
            path: '',
            name: '404Page',
            component: _404Page,
        }
    ],
} : {
    path: '/:path(.*)*',
    name: 'ErrorPage',
    meta: {
        title: 'ErrorPage',
        hideBreadcrumb: true,
    },
    component: _404Page,
} ;
